package top.leyi.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import top.leyi.entity.Approve;
import top.leyi.entity.SQLUtil;

import java.util.List;

public interface ApproveMapper {

    @Select("select * from approve where user_id = #{userId} and is_delete = 0")
    public List<Approve>  queryPersonalApprove(int userId);

    @Select("select * from approve where is_delete = 0 and state = #{id} LIMIT #{limit} OFFSET #{offset}")
    public List<Approve>  queryAllApprove(SQLUtil sqlUtil);


    @Delete("UPDATE approve set is_delete = 1 where id = #{value}")
    public void removeApprove(int id);

    @Update("UPDATE approve set state = 1 where id = #{value}")
    public void updateSucState(int id);

    @Update("UPDATE approve set state = 2 where id = #{value}")
    public void updateFailState(int id);

    @Insert("INSERT INTO approve(user_id,pics) values (#{user_id},#{pics})")
    public void addApprove(Approve approve);

    @Select("SELECT count(*) FROM approve WHERE user_id = #{user_id} and state = 0")
    public int countApprove(Approve approve);
}
